var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/businessComponent/work-flow/WFVerticalHisLayout.tsx
var WFVerticalHisLayout_exports = {};
__export(WFVerticalHisLayout_exports, {
  WFVerticalHisLayout: () => WFVerticalHisLayout
});
module.exports = __toCommonJS(WFVerticalHisLayout_exports);
var import_icons = require("@ant-design/icons");
var import_antd = require("antd");
var import_react = require("react");
var import_util = require("../../util");
var import_constVar = require("./constVar");
var import_service = require("./service");
var import_util2 = require("./util");
var webkitLineClampStyle = {
  display: "-webkit-box",
  WebkitBoxOrient: "vertical",
  overflow: "hidden",
  textOverflow: "ellipsis",
  WebkitLineClamp: 2,
  lineHeight: "1.5em"
};
var IcontMapp = {
  "1": import_constVar.submitIcon,
  "2": import_constVar.submitIcon,
  // 会签的同意/提交
  "3": import_constVar.rollbackIcon,
  // 会签的驳回/回退
  "4": import_constVar.rollbackIcon,
  "5": import_constVar.addSubTaskIcon,
  "6": import_constVar.reassignIcon,
  "90": import_constVar.taskRetrieveIcon,
  "99": import_constVar.terminateIcon
};
var approvalPointRener = (riskLevel) => {
  let approvalPointItem = { color: "#00CC33", name: "无风险" };
  switch (riskLevel) {
    case 1:
      approvalPointItem = { color: "#00CC33", name: "无风险" };
      break;
    case 2:
      approvalPointItem = { color: "#0081CC", name: "低" };
      break;
    case 3:
      approvalPointItem = { color: "#FE890C", name: "中" };
      break;
    case 4:
      approvalPointItem = { color: "red", name: "高" };
      break;
  }
  return approvalPointItem;
};
var InitWrapStyle = {
  width: "460px",
  backgroundColor: "#FFFFFF"
};
var postScriptListDom = (list) => {
  return /* @__PURE__ */ React.createElement(React.Fragment, null, list && list.length && list.map((v, idx) => {
    return /* @__PURE__ */ React.createElement(
      "div",
      {
        key: v.id,
        style: {
          padding: "6px 0",
          borderBottom: idx === list.length - 1 ? "none" : "1px solid rgba(0, 0, 0, .06)"
        }
      },
      /* @__PURE__ */ React.createElement("div", { style: { ...webkitLineClampStyle, width: "100%", maxHeight: "46px" } }, /* @__PURE__ */ React.createElement(import_antd.Tooltip, { title: v.postScript }, /* @__PURE__ */ React.createElement("span", null, v.postScript))),
      /* @__PURE__ */ React.createElement(
        "div",
        {
          style: {
            display: "flex",
            justifyContent: "space-between",
            fontSize: 12,
            padding: "3px 0"
          }
        },
        /* @__PURE__ */ React.createElement("span", null, v.insertDt),
        !!v.fileCount && /* @__PURE__ */ React.createElement("span", { onClick: () => (0, import_util2.showTaskAttachment)(v, 0), style: { color: "#0D81CC" } }, /* @__PURE__ */ React.createElement(import_icons.PaperClipOutlined, null), "(x", v.fileCount, ")")
      )
    );
  }));
};
var postScirptListCollapse = (postScriptList, index, opened, toggleShowMorePostScript) => {
  let text = opened ? "收起" : "展开更多";
  let icon = opened ? /* @__PURE__ */ React.createElement(import_icons.UpOutlined, null) : /* @__PURE__ */ React.createElement(import_icons.DownOutlined, null);
  const list = opened ? postScriptList : postScriptList.slice(0, 1);
  const renderText = () => {
    return /* @__PURE__ */ React.createElement(React.Fragment, null, postScriptListDom(list), /* @__PURE__ */ React.createElement(
      "div",
      {
        style: { height: "26px", fontSize: 12, color: "#0D81CC" },
        onClick: () => toggleShowMorePostScript(index, opened)
      },
      /* @__PURE__ */ React.createElement("span", null, text, " ", icon)
    ));
  };
  return /* @__PURE__ */ React.createElement("div", null, renderText());
};
var TextExpandCollapse = (text, expanded, index, toggleExpand) => {
  const maxChars = 75;
  const renderText = () => {
    if (expanded) {
      return /* @__PURE__ */ React.createElement(React.Fragment, null, text, /* @__PURE__ */ React.createElement(
        "span",
        {
          onClick: () => {
            toggleExpand(index, expanded);
          },
          style: { cursor: "pointer", color: "blue" }
        },
        "收起"
      ));
    }
    const shouldExpand = text.length > maxChars;
    return /* @__PURE__ */ React.createElement(React.Fragment, null, shouldExpand ? `${text.slice(0, maxChars - 4)}...` : text, shouldExpand && /* @__PURE__ */ React.createElement(
      "span",
      {
        onClick: () => {
          toggleExpand(index, expanded);
        },
        style: { cursor: "pointer", color: "#0D81CC" }
      },
      "查看全部"
    ));
  };
  return /* @__PURE__ */ React.createElement("div", null, renderText());
};
var hisData = [];
var subHisData = [];
var WfHistoryTimeline = ({ workFlowInfo }) => {
  const [historyList, setHistoryList] = (0, import_react.useState)(new Array());
  let toggleStateList = [];
  const handleToggleContent = async (index, state) => {
    toggleStateList[index] = !state;
    const hisDom = dataToDom(hisData);
    setHistoryList(hisDom);
  };
  let expendedStateList = [];
  const toggleExpand = (index, state) => {
    expendedStateList[index] = !state;
    const hisDom = dataToDom(hisData);
    setHistoryList(hisDom);
  };
  let toggleApprovalPointsStateList = [];
  const handleToggleApprovalPoints = async (index, state) => {
    toggleApprovalPointsStateList[index] = !state;
    const hisDom = dataToDom(subHisData.length > 0 ? subHisData : hisData);
    setHistoryList(hisDom);
  };
  let postScriptStateList = [];
  const toggleShowMorePostScript = (index, state) => {
    postScriptStateList[index] = !state;
    const hisDom = dataToDom(hisData);
    setHistoryList(hisDom);
  };
  const dataToDom = (data) => {
    return data.map((i, index) => {
      return {
        label: /* @__PURE__ */ React.createElement(
          "div",
          {
            style: {
              display: "flex",
              flexDirection: "column",
              alignItems: "center",
              textAlign: "center",
              marginRight: "-120px"
            }
          },
          /* @__PURE__ */ React.createElement("div", { style: { color: "#333333 " } }, i.actionName),
          /* @__PURE__ */ React.createElement("div", { style: { fontSize: "12px", width: "62px", color: "#666666 " } }, i.time)
        ),
        children: !i.hasOwnProperty("children") ? /* @__PURE__ */ React.createElement("div", { style: { height: !toggleStateList[index] ? "auto" : "60px" } }, /* @__PURE__ */ React.createElement(
          "div",
          {
            onClick: () => {
              handleToggleContent(index, toggleStateList[index]);
            },
            style: {
              width: "287px",
              height: "30px",
              backgroundColor: "#F2F3F4",
              display: "flex",
              alignItems: "center",
              paddingLeft: "27px",
              cursor: "pointer"
            }
          },
          /* @__PURE__ */ React.createElement("span", { style: { width: "10px" } }, !toggleStateList[index] ? import_constVar.arrowUpIcon : import_constVar.arrowDownIcon),
          /* @__PURE__ */ React.createElement("span", { style: { width: "20px", margin: "0 7px", paddingTop: "6px" } }, import_constVar.manIcon),
          /* @__PURE__ */ React.createElement("span", { style: { fontWeight: "bold" } }, i.nodeName)
        ), !toggleStateList[index] && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { style: { margin: "11px 0 6px  33px" } }, i.userName), /* @__PURE__ */ React.createElement("div", { style: { fontSize: "12px", width: "287px", color: "#666666 ", paddingLeft: "33px" } }, TextExpandCollapse(i.message, expendedStateList[index], index, toggleExpand)), !!i.postScriptList && /* @__PURE__ */ React.createElement(
          "div",
          {
            style: {
              backgroundColor: "#F2F3F4",
              borderRadius: "4px",
              width: "260px",
              margin: "11px 0px 6px 25px",
              cursor: "pointer",
              padding: "0 6px",
              height: postScriptStateList[index] ? "auto" : "104px"
            }
          },
          postScirptListCollapse(
            i.postScriptList,
            index,
            postScriptStateList[index],
            toggleShowMorePostScript
          )
        ), !!i.fileCount && /* @__PURE__ */ React.createElement("div", { style: { fontSize: "12px", width: "62px", color: "#666666 ", marginLeft: "33px" } }, "附件:", /* @__PURE__ */ React.createElement("span", { style: { color: "#0D81CC" } }, /* @__PURE__ */ React.createElement(
          import_icons.PaperClipOutlined,
          {
            onClick: () => {
              (0, import_util2.showTaskAttachment)(i, 0);
            }
          }
        ), i.fileCount)), !!i.approvalPoints && /* @__PURE__ */ React.createElement(
          "div",
          {
            style: { fontSize: "12px", width: "287px", marginLeft: "33px", color: "#666666", marginTop: "5px" }
          },
          /* @__PURE__ */ React.createElement(
            "span",
            {
              onClick: () => {
                handleToggleApprovalPoints(index, toggleApprovalPointsStateList[index]);
              },
              style: {
                display: "flex",
                alignItems: "center",
                color: "#000000",
                fontSize: "14px",
                fontWeight: "bold",
                cursor: "pointer",
                position: "relative",
                left: "-34px"
              }
            },
            toggleApprovalPointsStateList[index] ? import_constVar.arrowDownIcon1 : import_constVar.arrowDownIcon2,
            /* @__PURE__ */ React.createElement("span", { style: { marginLeft: "5px" } }, "审批要点:")
          ),
          toggleApprovalPointsStateList[index] && i.approvalPointRuntimeDtoList.map((j, index2) => {
            var _a, _b, _c, _d, _e;
            return /* @__PURE__ */ React.createElement("div", { style: { marginTop: "10px" } }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
              "span",
              {
                style: {
                  display: "inline-block",
                  width: "16px",
                  height: "16px",
                  borderRadius: "50%",
                  backgroundColor: "#0081cc",
                  color: "#ffffff",
                  textAlign: "center",
                  fontSize: "12px",
                  lineHeight: "16px",
                  marginRight: "2px"
                }
              },
              index2 + 1
            ), /* @__PURE__ */ React.createElement("span", { style: { fontWeight: "bold" } }, j.name)), /* @__PURE__ */ React.createElement("div", { style: { marginLeft: "18px" } }, j.description), /* @__PURE__ */ React.createElement(
              "div",
              {
                style: {
                  color: approvalPointRener((_a = j.details) == null ? void 0 : _a[0].riskLevel).color,
                  marginLeft: "18px",
                  marginBottom: "5px",
                  fontWeight: "bold"
                }
              },
              approvalPointRener((_b = j.details) == null ? void 0 : _b[0].riskLevel).name
            ), /* @__PURE__ */ React.createElement(
              "div",
              {
                style: {
                  width: "max-content",
                  border: "1px solid #0281CC",
                  borderRadius: "3px",
                  marginLeft: "18px",
                  padding: "3px 6px 3px 6px",
                  color: "#0281CC",
                  backgroundColor: "#E5F8FF "
                }
              },
              (_c = j.details) == null ? void 0 : _c[0].optionValue
            ), ((_d = j.details) == null ? void 0 : _d[0].remark) && /* @__PURE__ */ React.createElement("div", null, "备注：", (_e = j.details) == null ? void 0 : _e[0].remark));
          })
        ))) : /* @__PURE__ */ React.createElement(
          "div",
          {
            style: {
              height: "50px"
            }
          },
          /* @__PURE__ */ React.createElement(
            "div",
            {
              onClick: () => {
                const hisDom = dataToDom(i.children);
                subHisData = i.children;
                setHistoryList(hisDom);
              },
              style: {
                width: "287px",
                height: "30px",
                backgroundColor: "#F2F3F4",
                display: "flex",
                alignItems: "center",
                paddingLeft: "22px",
                cursor: "pointer"
              }
            },
            /* @__PURE__ */ React.createElement("span", { style: { width: "20px", margin: "0 7px", paddingTop: "6px" } }, import_constVar.subProcessIcon),
            /* @__PURE__ */ React.createElement("span", { style: { fontWeight: "bold" } }, "子流程")
          )
        ),
        dot: /* @__PURE__ */ React.createElement("span", null, IcontMapp[i.action ? i.action : "1"])
      };
    });
  };
  (0, import_util.useAsyncEffect)(async () => {
    hisData = await (0, import_service.getWorkFlowHis)({ procInstId: workFlowInfo.procInstId || "" });
    const hisDom = dataToDom(hisData);
    setHistoryList(hisDom);
  }, [workFlowInfo.procInstId]);
  return /* @__PURE__ */ React.createElement(import_antd.Timeline, { style: { position: "relative", left: "-100px", paddingTop: "40px" }, mode: "left", items: historyList });
};
function WFVerticalHisLayout({ workFlowInfo, styles = void 0 }) {
  const wrapStyle = styles ? styles : InitWrapStyle;
  (0, import_util.useAllReady)(() => {
    (0, import_util2.setWorkFlowUIState)(workFlowInfo.formDataPermissions, workFlowInfo.menuPermissions);
  });
  return /* @__PURE__ */ React.createElement(import_util.Layout, { style: wrapStyle }, /* @__PURE__ */ React.createElement(WfHistoryTimeline, { workFlowInfo }));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  WFVerticalHisLayout
});
